<!DOCTYPE html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<title>我的申报</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />

    <style>
    	html, body {width: 100%;min-height: 100%;background: #fff;}
    	.h20 {height: 0.5rem;background: #f0f0f0;}

		/* 无数据块 */
		.enshrine_wu_box_fiexd {position: fixed;top: 0;left: 0;background-color: #fff;width: 100%;height: 100vh;}
		.enshrine_wu_box {height: 100%;display: table;}
		.enshrine_wu {text-align: center;height: 100%;display: table-cell;vertical-align: middle;}
		.enshrine_wu_ico {width: 85%;margin: 0 auto 20px;}
		.enshrine_wu_txt {font-size: 20px;color: #4d4d4d;}


		/* 数据 */
    .declare li .aui-list-item {
      padding: 0.75rem;
    }
    .declare .aui-list-item-right h5 {
      color: #ff9800;
    }
		.declare .aui-list-item-right h4 {
      color: red;
    }
    .declare .aui-list-item-right h6 {
      color: #2997e4;
    }
    .declare .aui-list-item-title h5 {
      color: #333;
    }
    .declare .aui-list-item-title h6 {
      color: #999;
    }
		.declare {
			min-height: calc(100vh - 65px);
		}
    </style>
</head>
<body>

	<section class="aui-refresh-content">
	<div id="app" v-cloak>

		<!-- 无数据时显示 -->
		<div v-if="code == 1" class="enshrine_wu_box_fiexd">
			<div class="enshrine_wu_box">
				<div class="enshrine_wu">
					<img src="../../image/enshrine_list_wu_ico.png" class="enshrine_wu_ico" alt="">
					<div class="enshrine_wu_txt">还没有申报...</div>
				</div>
			</div>
		</div>


  <div v-else class="aui-content aui-margin-b-15 declare">
	    <ul class="aui-list aui-list-in">
	        <li v-for="item in newsList" tapmode="presshover" @click="openNewWindow(item.id,'mydeclarationform','申报详情')">
	            <div class="aui-list-item-inner aui-list-item">
	                <div class="aui-list-item-title">
										<h5>{{item.title}}</h5>
										<h6>{{item.declareTime}}</h6>
									</div>
	                <div class="aui-list-item-right">
										<h6 v-if="item.status == 0">审核通过</h6>
										<h4 v-else-if="item.status == 1">审核不通过</h4>
	                	<h5 v-else>未审核</h5>
	                </div>
	            </div>
	        </li>
	    </ul>
	</div>

</div>

</section>

</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript">

apiready = function() {
	var URL = 'http://kexiecs.unohacha.com/kexieScore';

	var app = new Vue({
		el: '#app',
		data: {
			newsList: [],
			token:'',
			page: 1,
			code: 1,
			totalpage: 2
		},
		created: function() {
			var $_this = this;
			$_this.token = $api.getStorage('token') || '';
			if(!$api.getStorage('token')){
        api.confirm( {
            title: '是否登录',
            msg: '确认是否登录？',
            buttons: [ '确定', '取消' ]
          }, function ( ret, err ) {
            var index = ret.buttonIndex;
            if ( index == 1 ) {
              api.openWin({
                name: 'login',
                url: '../five_frame/login_header.html',
                delay: 200,
                bounces: false
              });
              return;
            } else {
              api.closeWin({
                  name: name
              });
              return
            }
          })
          return
        }

			api.ajax({
				url: window.Url.getDeclareList + $_this.page,
				timeout: 300,
				headers: {
					'baseParams':$_this.token
				},
			}, function(ret, err) {
					if (ret.code == 0) {
							// api.alert({ msg: JSON.stringify(ret) });
							if (ret.code == 2) {
                  alert('用户未登录，请返回登录')
                  $api.rmStorage('token')
                  $api.rmStorage('data')
                  goback()
                   return
                }
							$_this.code = ret.code
							$_this.totalpage = ret.data.totalpage
							$_this.newsList = ret.data.newsList

					}else if(ret.code == 1) {

					} else {
							api.alert({ msg: JSON.stringify(err) });
					}
			})


			var pullRefresh = new auiPullToRefresh({
	        container: document.querySelector('.aui-refresh-content'),
	        triggerDistance: 100
	    },function(ret){
	        if(ret.status=="success"){
						$_this.page = 1
						api.ajax({
							url: window.Url.getDeclareList + $_this.page,
							timeout: 300,
							headers: {
								'baseParams':$_this.token
							},
						}, function(ret, err) {
								if (ret.code == 0) {
										// api.alert({ msg: JSON.stringify(ret) });
										setTimeout(function() {
										$_this.code = ret.code
										$_this.totalpage = ret.data.totalpage
										$_this.newsList = ret.data.newsList
										pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
									},500)

								}else if(ret.code == 1) {
									pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
								} else {
										api.alert({ msg: JSON.stringify(err) });
								}
						})

	        }
	    });

				var scroll = new auiScroll({
						listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
						distance:40 //判断到达底部的距离，isToBottom为true
				},function(ret){
					 if (ret.isToBottom) {
						 $_this.page ++
						 if ($_this.page > $_this.totalpage) {
							 $_this.page = $_this.totalpage
							 return
						 }
						 api.ajax({
			 				url: window.Url.getDeclareList + $_this.page,
							timeout: 300,
						}, function(ret, err) {
								if (ret) {
									if (ret.code == 0) {
									 //  api.alert({ msg: JSON.stringify(ret) });
										$_this.newsList = $_this.newsList.concat(ret.data.newsList)
									}
								} else {
										api.alert({ msg: JSON.stringify(err) });
								}
						})
					 }

				});

		},
		filters: {
		  time: function (value) {
		    value = new Date(value)
		    return value.getFullYear() + '-' + value.getMonth() + '-' + value.getDate() + ' ' + value.getHours() + ':' + value.getMinutes() + ':' + value.getSeconds()
		  }
		},
		methods: {
			openLogin:function (){
				api.openWin({
					name: 'login',
					url: './login_header.html',
					bounces: false,
					delay:200
				});
			},
			openNewWindow:function (id,type,title){
				api.openWin({
					name: type,
					url: './forth_header.html',
					pageParam: {id: id,name: type,title: title},
					bounces: false,
					delay:200
				});
			}
		}
	})
}

  function goback () {
    api.closeWin({name:api.pageParam.name});
  }


</script>
</html>
